package com.wanmait.community.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.wanmait.community.validation.admin.InsertGroup;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;

/**
 * 员工表
 */
@Data
@Accessors(chain = true)
@TableName(value = "`admin`")
public class Admin {
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 用户名
     */
    @TableField(value = "admin_name")
    @NotEmpty(message = "姓名不能为空")
    @Length(min = 2,message = "姓名的长度必须在2个字符以上")
    private String adminName;

    /**
     * 密码
     */
    @TableField(value = "admin_pass")
    @NotEmpty(message = "密码不能为空")
    private String adminPass;

    /**
     * 账号状态0正常1异常
     */
    @TableField(value = "stop")
    private Boolean stop;

    /**
     * 电话
     */
    @TableField(value = "phone")
    @NotEmpty(message = "电话不能为空")
    @Pattern(regexp = "^1[3-9]\\d{9}$",message = "手机号码格式不正确")
    private String phone;

    /**
     * 邮箱
     */
    @TableField(value = "email")
    @NotEmpty(message = "邮箱不能为空")
    @Email(message = "邮箱格式不正确")
    private String email;

    /**
     * 性别
     */
    @TableField(value = "gender")
    @NotEmpty(message = "性别不能为空",groups = {InsertGroup.class})
    @Pattern(regexp = "^[男女]$",message = "性别只能是男或女",groups = {InsertGroup.class})
    private String gender;

    /**
     * 身份证号
     */
    @TableField(value = "in_num")
    @NotEmpty(message = "身份证号不能为空",groups = {InsertGroup.class})
    @Pattern(regexp = "^\\d{17}[\\dXx]$",message = "身份证号不正确",groups = {InsertGroup.class})
    private String inNum;

    /**
     * 身份证照片正面
     */
    @TableField(value = "photo_right")
    private String photoRight;

    /**
     * 身份证照片反面
     */
    @TableField(value = "photo_back")
    private String photoBack;

    /**
     * 创建人用户id
     */
    @TableField(value = "creat_by")
    private Integer creatBy;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    @TableField(value = "creat_time")
    private Date creatTime;

    /**
     * 更新人用户id
     */
    @TableField(value = "update_by")
    private Integer updateBy;

    /**
     * 更新时间
     */
    @TableField(value = "update_time")
    private Date updateTime;

    /**
     * 最后登录时间
     */
    @TableField(value = "login_time")
    private Date loginTime;

    /**
     * 最后登录ip
     */
    @TableField(value = "login_ip")
    private String loginIp;

    /**
     * 逻辑删除1未删，0删除
     */
    @TableField(value = "`enable`")
    private Boolean enable;
}